package com.da.javatest.leetCode2;

public class Code223 {
    public int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
        int total = (C - A) * (D - B) + (G - E) * (H - F);
        int subTotal;
        //不相交的情况
        if (B >= H || F >= D || E >= C || A >= G) {
            subTotal = 0;
        } else {
            subTotal = (Math.min(C, G) - Math.max(E, A)) * (Math.min(D, H) - Math.max(B, F));
        }
        return total - subTotal;
    }
}
